/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package UTILITARIOS;


import CONTROLES.Conexion;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Time;
import java.util.TimeZone;



/**
 *
 * @author Administrador
 */
public class Hora {

    public String getHora()
    {
        String res="";
        Conexion conection = new Conexion();
        try {
           Connection conec = conection.getConexion();
           PreparedStatement ps = conec.prepareStatement("select CURRENT_TIME;");
           ResultSet consulta = ps.executeQuery();
           //TimeZone t = TimeZone.getTimeZone("America/La_Paz");
           while(consulta.next())
           {
               Time hora = consulta.getTime(1);
               
              res = hora.toString();
              // res = t.getID();
           }
        } catch (Exception e) {
            System.out.println("Ocurrio un error al obtener la hora" +e.getLocalizedMessage());
        }
        return res;
    }

     public Time getHoraTime()
    {
        Time res=null;
        Conexion conection = new Conexion();
        try {
           Connection conec = conection.getConexion();
           PreparedStatement ps = conec.prepareStatement("select CURRENT_TIME;");
           ResultSet consulta = ps.executeQuery();
           //TimeZone t = TimeZone.getTimeZone("America/La_Paz");
           while(consulta.next())
           {
                res = consulta.getTime(1);

              
           }
        } catch (Exception e) {
            System.out.println("Ocurrio un error al obtener la hora" +e.getLocalizedMessage());
        }
        return res;
    }

    public static void main(String[] args) {
        Hora h = new Hora();
        System.out.println("h = " +h.getHora());
    }

}
